package com.glsc.ngateway.common.base.domain.mysql.gateway;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.glsc.ngateway.common.base.domain.mysql.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import java.time.LocalDateTime;


/**
 * @author xuchang
 */
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Data
@MappedSuperclass
public class FlowFormBaseEntity extends BaseEntity {

    private static final long serialVersionUID = 9047289613781760365L;

    @Column(name = "process_id", columnDefinition = "varchar(64) comment '唯一编号'")
    private String processId;

    @Column(name = "process_title", columnDefinition = "varchar(1024) comment '流程名称'")
    private String processTitle;

    @Column(name = "flow_urgent_level", columnDefinition = "varchar(32) comment '紧急程度'")
    private String flowUrgentLevel;

    @Column(name = "process_create_time", columnDefinition = "datetime comment '申请日期'")
    @org.hibernate.annotations.CreationTimestamp
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime processCreateTime;

    @Column(name = "flow_creator_name", columnDefinition = "varchar(32) comment '申请人'")
    private String flowCreateOperatorName;

    @Column(name = "flow_creator_account", columnDefinition = "varchar(32) comment '发起人账户'")
    private String flowCreateOperatorAccount;

    @Column(name = "flow_creator_department", columnDefinition = "varchar(64) comment '申请人部门'")
    private String flowCreatorDepartment;

    @Column(name = "flow_creator_company", columnDefinition = "varchar(64) comment '申请人公司'")
    private String flowCreatorCompany;

    @Column(name = "system_name", columnDefinition = "varchar(200) comment '系统名称，从it网关取'")
    private String systemName;

    @Column(name = "system_code", columnDefinition = "varchar(30) comment '系统名称，从it网关取，后续关联团队人员'")
    private String systemCode;

    @Column(name = "system_admin_name", columnDefinition = "varchar(30) comment '系统管理员姓名'")
    private String systemAdminName;

    @Column(name = "system_admin_account", columnDefinition = "varchar(30) comment '系统管理员账户'")
    private String systemAdminAccount;

    @Column(name = "status", columnDefinition = "varchar(16) comment '流程状态'")
    private String status;

    @Column(name = "is_close", columnDefinition = "int(2) default 0 comment '是否完成0 未完成 1已完成'")
    private int isClose;
}
